define(function(require) {
	require("jquery");
	var appInfo = require('app/AppInfo');
	var c = require('app/utils/CommonUtils');
	var hc = require('app/utils/HttpClientUtils');
	var tip = require('app/utils/TipUtils');
	var dbu = require('app/utils/DBUtils');
	var UserInfoUtils = require('app/utils/UserInfoUtils');
	var win = window;
	var action = {};
	
	action.closeWin = function(){
		api.closeToWin({
		    name: 'root'
		});
	}
	action.openPasswordForgetWin = function() {
		var name = "FindPasswodWin";
		api.openWin({
			name : name,
			url : './' + name + '.html',
			rect : {
				x : 0,
				y : 0,
				w : api.frameWidth,
				h : api.frameHeight
			},
		});
	}
	action.login = function() {
		var tel = $("#tel_number").val();
		var pwd = $("#password").val();
		
		if(!c.isTel(tel)){
			tip.show("请正确输入手机号");
			return;
		}
		
		if(c.isNullStr(pwd)){
			tip.show("登陆密码不能为空");
			return;
		}
		
		var url = appInfo.serverbase + "/luyan/login/tel/"+tel+"/pwd/"+pwd;
		hc.post(url, null, function(resp){
			
			if(resp.status == 200){
				var user = resp.result;
				if(c.isNull(user)){
					tip.show("登陆密码不正确");
				}else{
					UserInfoUtils.saveUser(user);
					action.closeWin();
				}
			}
		});
	}
	action.openRegistWin = function() {
		var name = "RegistWin";
		api.openWin({
			name : name,
			url : './' + name + '.html',
			rect : {
				x : 0,
				y : 0,
				w : api.frameWidth,
				h : api.frameHeight
			},
		});
	}
	return action;
});
